<!-- src/components/AdminHeader.vue -->
<template>
  <div class="admin-header">
    <div class="header-left">
      <div class="system-title">MES平台管理系统</div>
    </div>
    <div class="header-right">
      <el-dropdown>
        <span class="user-info">
          <el-icon><user /></el-icon>
          <span class="username">管理员</span>
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item @click="logout">退出登录</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>

<script setup>
import { User } from '@element-plus/icons-vue'
import { useRouter } from 'vue-router'
import { useTokenStore } from '@/stores/token'

const router = useRouter()
const tokenStore = useTokenStore()

const logout = () => {
  tokenStore.removeToken()
  router.push('/login')
}
</script>

<style scoped>
.admin-header {
  height: 60px;
  background: #fff;
  box-shadow: 0 2px 12px #0000001a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.system-title {
  font-size: 20px;
  font-weight: 600;
  color: #1890ff;
}

.user-info {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 0 12px;
}

.username {
  margin-left: 8px;
}
</style>